<div class="problemindexholder" problemindex="A">
 <div class="ttypography">
  <div class="problem-statement">
   <div class="header">
    <div class="title">
     A. Office Keys
    </div>
    <div class="time-limit">
     <div class="property-title">
      time limit per test
     </div>
     2 seconds
    </div>
    <div class="memory-limit">
     <div class="property-title">
      memory limit per test
     </div>
     256 megabytes
    </div>
    <div class="input-file">
     <div class="property-title">
      input
     </div>
     standard input
    </div>
    <div class="output-file">
     <div class="property-title">
      output
     </div>
     standard output
    </div>
   </div>
   <div>
    <p>
     There are
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     people and
     <span class="tex-span">
      <i>
       k
      </i>
     </span>
     keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken by somebody, it couldn't be taken by anybody else.
    </p>
    <p>
     You are to determine the minimum time needed for all
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     people to get to the office with keys. Assume that people move a unit distance per
     <span class="tex-span">
      1
     </span>
     second. If two people reach a key at the same time, only one of them can take the key. A person can pass through a point with a key without taking it.
    </p>
   </div>
   <div class="input-specification">
    <div class="section-title">
     Input
    </div>
    <p>
     The first line contains three integers
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     ,
     <span class="tex-span">
      <i>
       k
      </i>
     </span>
     and
     <span class="tex-span">
      <i>
       p
      </i>
     </span>
     (
     <span class="tex-span">
      1 ≤
      <i>
       n
      </i>
      ≤ 1 000
     </span>
     ,
     <span class="tex-span">
      <i>
       n
      </i>
      ≤
      <i>
       k
      </i>
      ≤ 2 000
     </span>
     ,
     <span class="tex-span">
      1 ≤
      <i>
       p
      </i>
      ≤ 10
      <sup class="upper-index">
       9
      </sup>
     </span>
     ) — the number of people, the number of keys and the office location.
    </p>
    <p>
     The second line contains
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     distinct integers
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       1
      </sub>
      ,
      <i>
       a
      </i>
      <sub class="lower-index">
       2
      </sub>
      , ...,
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        n
       </i>
      </sub>
     </span>
     (
     <span class="tex-span">
      1 ≤
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
      </sub>
      ≤ 10
      <sup class="upper-index">
       9
      </sup>
     </span>
     ) — positions in which people are located initially. The positions are given in arbitrary order.
    </p>
    <p>
     The third line contains
     <span class="tex-span">
      <i>
       k
      </i>
     </span>
     distinct integers
     <span class="tex-span">
      <i>
       b
      </i>
      <sub class="lower-index">
       1
      </sub>
      ,
      <i>
       b
      </i>
      <sub class="lower-index">
       2
      </sub>
      , ...,
      <i>
       b
      </i>
      <sub class="lower-index">
       <i>
        k
       </i>
      </sub>
     </span>
     (
     <span class="tex-span">
      1 ≤
      <i>
       b
      </i>
      <sub class="lower-index">
       <i>
        j
       </i>
      </sub>
      ≤ 10
      <sup class="upper-index">
       9
      </sup>
     </span>
     ) — positions of the keys. The positions are given in arbitrary order.
    </p>
    <p>
     Note that there can't be more than one person or more than one key in the same point. A person and a key can be located in the same point.
    </p>
   </div>
   <div class="output-specification">
    <div class="section-title">
     Output
    </div>
    <p>
     Print the minimum time (in seconds) needed for all
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     to reach the office with keys.
    </p>
   </div>
   <div class="sample-tests">
    <div class="section-title">
     Examples
    </div>
    <div class="sample-test">
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>2 4 50<br/>20 100<br/>60 10 40 80<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>50<br/></pre>
     </div>
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>1 2 10<br/>11<br/>15 7<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>7<br/></pre>
     </div>
    </div>
   </div>
   <div class="note">
    <div class="section-title">
     Note
    </div>
    <p>
     In the first example the person located at point
     <span class="tex-span">
      20
     </span>
     should take the key located at point
     <span class="tex-span">
      40
     </span>
     and go with it to the office located at point
     <span class="tex-span">
      50
     </span>
     . He spends
     <span class="tex-span">
      30
     </span>
     seconds. The person located at point
     <span class="tex-span">
      100
     </span>
     can take the key located at point
     <span class="tex-span">
      80
     </span>
     and go to the office with it. He spends
     <span class="tex-span">
      50
     </span>
     seconds. Thus, after
     <span class="tex-span">
      50
     </span>
     seconds everybody is in office with keys.
    </p>
   </div>
  </div>
  <p>
  </p>
 </div>
</div>
